Usefulness of $r->notes and $r->pnotes (or $c)

Usefulness of $r->notes and $r->pnotes (or $c)

am 23.03.2010 22:28:01 von Michael Ludwig

Let me bore you some more.

First, ModPerl::MethodLookup::lookup_method( $symbol ) is a really great
help for exploring the API!

milu@colinux:~ > perl aplkp.pl notes
There is more than one class with method 'notes'
try one of:
use Apache2::RequestRec ();
use Apache2::Connection ();

milu@colinux:~ > perl aplkp.pl pnotes
There is more than one class with method 'pnotes'
try one of:
use Apache2::RequestUtil ();
use Apache2::ConnectionUtil ();

Good. Now to the point. We have ->notes and ->pnotes on the request and
connection objects. I've passed some information from mod_perl on to
mod_php5 using the notes table. Cool. I could pass complex data from one
mod_perl handler to the other using the pnotes table. Also cool.

It's all in-process, which is cool. It's all per-request (or, if you
want, per-connection), which sets the scope of its usefulness.

The notes are an APR::Table, the pnotes are a HASH.

What real-life uses have you found for these notes and pnotes?

What could be done at the connection level? Or is this rather too
low-level for run-of-the-mill web applications?

This is by curiosity and to get my imagination going.
--
Michael Ludwig

Re: Usefulness of $r->notes and $r->pnotes (or $c)

am 23.03.2010 22:34:27 von mpeters

On 03/23/2010 05:28 PM, Michael Ludwig wrote:

> What could be done at the connection level?

Anything that might involve keep alive connections: where the same
connection serves multiple requests. Probably not that useful for HTTP,
but might be for other protocols.

--
Michael Peters
Plus Three, LP

Re: Usefulness of $r->notes and $r->pnotes (or $c)

am 24.03.2010 00:39:29 von Adam Prime

Michael Peters wrote:
> On 03/23/2010 05:28 PM, Michael Ludwig wrote:
>
>> What could be done at the connection level?
>
> Anything that might involve keep alive connections: where the same
> connection serves multiple requests. Probably not that useful for HTTP,
> but might be for other protocols.
>

Fred did something fancy (connection rate limiting) with $c->pnotes
recently. see his post about it here:

http://marc.info/?l=apache-modperl&m=124217947427395&w=2

Re: Usefulness of $r->notes and $r->pnotes (or $c)

am 24.03.2010 11:32:03 von Michael Ludwig

Am 24.03.2010 um 00:39 schrieb Adam Prime:
> Michael Peters wrote:
>> On 03/23/2010 05:28 PM, Michael Ludwig wrote:
>>=20
>>> What could be done at the connection level?
>>=20
>> Anything that might involve keep alive connections: where the same=20
>> connection serves multiple requests. Probably not that useful for HTTP,=
=20
>> but might be for other protocols.
>>=20
>=20
> Fred did something fancy (connection rate limiting) with $c->pnotes=20
> recently. see his post about it here:
>=20
> http://marc.info/?l=3Dapache-modperl&m=3D124217947427395&w=3 D2

That's interesting, thanks. But it makes me wonder:

# make 'em wait
sleep 5;
return Apache2::Const::HTTP_SERVICE_UNAVAILABLE;

This puts both the server process and the client to sleep for five seconds =
before returning. However, the server process is likely heavy-weight, where=
as the client process is likely light-weight, and easily multi-threaded. So=
I'm wondering if this throttler, which seems to have worked fine for Fred,=
is viable in the general case.

--=20
Michael.Ludwig (#) XING.com

Re: Usefulness of $r->notes and $r->pnotes (or $c)

am 24.03.2010 13:17:52 von Perrin Harkins

On Wed, Mar 24, 2010 at 6:32 AM, Michael Ludwig wrote:
> This puts both the server process and the client to sleep for five seconds before returning.
> However, the server process is likely heavy-weight, whereas the client process is likely light-
> weight, and easily multi-threaded. So I'm wondering if this throttler, which seems to have
> worked fine for Fred, is viable in the general case.

It used to be safe to assume that anyone running mod_perl had a
bottleneck on memory and the number of processes they can run. This
isn't always true anymore. Some people have plenty of headroom for
mod_perl processes but can't allow frequent access to a shared
resource like a fragile database.

The request pnotes is commonly used to pass information between
handlers in different phases. I haven't seen much use of the
connection pnotes.

- Perrin

Re: Usefulness of $r->notes and $r->pnotes (or $c)

am 24.03.2010 15:20:48 von Doug Sims

--00151747948c0077af04828ca3e1
Content-Type: text/plain; charset=ISO-8859-1

We use the notes table to put a reference to the session (and thus the user)
in the access log.

$request->notes->set('session' => $session->{SESSION});

This is in apache2.conf:

LogFormat "%v:%p %h %l %u %t \"%r\" %>s %b \"%{Referer}i\"
\"%{User-Agent}i\" %{session}n" combined_with_session

This makes it possible to differentiate log entries by user, whether
multiple users have the same ip address or if a user's address changes.



On Tue, Mar 23, 2010 at 4:28 PM, Michael Ludwig wrote:

> Let me bore you some more.
>
> First, ModPerl::MethodLookup::lookup_method( $symbol ) is a really great
> help for exploring the API!
>
> milu@colinux:~ > perl aplkp.pl notes
> There is more than one class with method 'notes'
> try one of:
> use Apache2::RequestRec ();
> use Apache2::Connection ();
>
> milu@colinux:~ > perl aplkp.pl pnotes
> There is more than one class with method 'pnotes'
> try one of:
> use Apache2::RequestUtil ();
> use Apache2::ConnectionUtil ();
>
> Good. Now to the point. We have ->notes and ->pnotes on the request and
> connection objects. I've passed some information from mod_perl on to
> mod_php5 using the notes table. Cool. I could pass complex data from one
> mod_perl handler to the other using the pnotes table. Also cool.
>
> It's all in-process, which is cool. It's all per-request (or, if you
> want, per-connection), which sets the scope of its usefulness.
>
> The notes are an APR::Table, the pnotes are a HASH.
>
> What real-life uses have you found for these notes and pnotes?
>
> What could be done at the connection level? Or is this rather too
> low-level for run-of-the-mill web applications?
>
> This is by curiosity and to get my imagination going.
> --
> Michael Ludwig
>

--00151747948c0077af04828ca3e1
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

We use the notes table to put a reference to the session (and thus the user=
) in the access log.

$request->notes->set('session' =
=3D> $session->{SESSION});

This is in apache2.conf:

=A0=
LogFormat "%v:%p %h %l %u %t \"%r\" %>s %b \"%{Refe=
rer}i\" \"%{User-Agent}i\" %{session}n" combined_with_s=
ession


This makes it possible to differentiate log entries by user, whether mu=
ltiple users have the same ip address or if a user's address changes. r>


On Tue, Mar 23, 2010 at 4:28 PM, M=
ichael Ludwig <milu71=
@gmx.de
>
wrote:

204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Let me bore you s=
ome more.



First, ModPerl::MethodLookup::lookup_method( $symbol ) is a really great >
help for exploring the API!



milu@colinux:~ > perl aplk=
p.pl
notes

There is more than one class with method 'notes'

try one of:

=A0 =A0 =A0 =A0use Apache2::RequestRec ();

=A0 =A0 =A0 =A0use Apache2::Connection ();



milu@colinux:~ > perl aplk=
p.pl
pnotes

There is more than one class with method 'pnotes'

try one of:

=A0 =A0 =A0 =A0use Apache2::RequestUtil ();

=A0 =A0 =A0 =A0use Apache2::ConnectionUtil ();



Good. Now to the point. We have ->notes and ->pnotes on the request a=
nd

connection objects. I've passed some information from mod_perl on to >
mod_php5 using the notes table. Cool. I could pass complex data from one >
mod_perl handler to the other using the pnotes table. Also cool.



It's all in-process, which is cool. It's all per-request (or, if yo=
u

want, per-connection), which sets the scope of its usefulness.



The notes are an APR::Table, the pnotes are a HASH.



What real-life uses have you found for these notes and pnotes?



What could be done at the connection level? Or is this rather too

low-level for run-of-the-mill web applications?



This is by curiosity and to get my imagination going.

--

Michael Ludwig




--00151747948c0077af04828ca3e1--

Re: Usefulness of $r->notes and $r->pnotes (or $c)

am 24.03.2010 15:46:37 von Michael Ludwig

Am 24.03.2010 um 15:20 schrieb Douglas Sims:

> We use the notes table to put a reference to the session (and thus the us=
er) in the access log.
>=20
> $request->notes->set('session' =3D> $session->{SESSION});
>=20
> This is in apache2.conf:
>=20
> LogFormat "%v:%p %h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Age=
nt}i\" %{session}n" combined_with_session
>=20
> This makes it possible to differentiate log entries by user, whether mult=
iple users have the same ip address or if a user's address changes.

That's a useful one!

I used the notes table for interop with mod_php5. Does anyone use the notes=
table for interop with some Ruby or Python extension for Apache? I'd be pa=
rticularly interested in Perl/Ruby interop within Apache.
--=20
Michael.Ludwig (#) XING.com

Re: Usefulness of $r->notes and $r->pnotes (or $c)

am 25.03.2010 04:39:15 von Fred Moyer

On Wed, Mar 24, 2010 at 3:32 AM, Michael Ludwig w=
rote:
> Am 24.03.2010 um 00:39 schrieb Adam Prime:
>> Michael Peters wrote:
>>> On 03/23/2010 05:28 PM, Michael Ludwig wrote:
>>>
>>>> What could be done at the connection level?
>>>
>>> Anything that might involve keep alive connections: where the same
>>> connection serves multiple requests. Probably not that useful for HTTP,
>>> but might be for other protocols.
>>>
>>
>> Fred did something fancy (connection rate limiting) with $c->pnotes
>> recently. =A0see his post about it here:
>>
>> http://marc.info/?l=3Dapache-modperl&m=3D124217947427395&w=3 D2
>
> That's interesting, thanks. But it makes me wonder:
>
> =A0 =A0 =A0 =A0# make 'em wait
> =A0 =A0 =A0 =A0sleep 5;
> =A0 =A0 =A0 =A0return Apache2::Const::HTTP_SERVICE_UNAVAILABLE;
>
> This puts both the server process and the client to sleep for five second=
s before returning. However, the server process is likely heavy-weight, whe=
reas the client process is likely light-weight, and easily multi-threaded. =
So I'm wondering if this throttler, which seems to have worked fine for Fre=
d, is viable in the general case.

I really don't know if this sleep was useful; who knows, maybe it is
the reverse of useful in that it causes concurrent connections to pile
up rather than process them quickly and return to the client. Some
clients make a lot of connections in parallel, some in serial, this
was meant to target the ones that make connections in serial. Short
bursts were the target to throttle as opposed to a large number of
connections at once.